﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using MySpace.Data;
/// <summary>
///NewsTable 的摘要说明
/// </summary>
namespace DataBaseTable
{
    public class NewsTable:DBTable
    {
        private const string tableName = "news";
        public NewsTable()
            : base(GetHandler.Init(), tableName)
        {
            this.GetRow();
            //没有参数重载
        }
        public NewsTable(int Newid)
            : base(GetHandler.Init(), tableName)
        {
            this.Filter = "id=?";
            this.AddParameter("id", Newid);
            this.GetRow();
            //有参数重载
        }

        /// <summary>
        /// ID
        /// </summary>
        public int ID
        {
            get
            {
                try { return (int)this.DataRow["id"]; }
                catch { return 0; }
            }
        }
        /// <summary>
        /// 大类ID
        /// </summary>
        public int BigClassId
        {
            get
            {
                try { return (int)this.DataRow["BigClassId"]; }
                catch { return 0; }
            }
            set
            {
                this.DataRow["BigClassId"] = value;
            }
        }
        /// <summary>
        /// 小类ID
        /// </summary>
        public int SmallClassId
        {
            get
            {
                try { return (int)this.DataRow["SmallClassId"]; }
                catch { return 0; }
            }
            set
            {
                this.DataRow["SmallClassId"] = value;
            }
        }
        
        /// <summary>
        /// 置顶
        /// </summary>
        public int IsTop
        {
            get
            {
                try { return (int)this.DataRow["IsTop"]; }
                catch { return 0; }
            }
            set
            {
                this.DataRow["IsTop"] = value;
            }
        }
        /// <summary>
        /// 新闻标题
        /// </summary>
        public string NewTitle
        {
            get
            {
                try { return (string)this.DataRow["NewTitle"]; }
                catch { return string.Empty; }
            }
            set
            {
                this.DataRow["NewTitle"] = value;
            }
        }        
        /// <summary>
        /// 外部URL
        /// </summary>
        public string OutUrl
        {
            get
            {
                try { return (string)this.DataRow["OutUrl"]; }
                catch { return string.Empty; }
            }
            set
            {
                this.DataRow["OutUrl"] = value;
            }
        }
        /// <summary>
        /// 内容
        /// </summary>
        public string Contents
        {
            get
            {
                try { return (string)this.DataRow["Contents"]; }
                catch { return string.Empty; }
            }
            set
            {
                this.DataRow["Contents"] = value;
            }
        }        
        /// <summary>
        /// 无htm代码的内容
        /// </summary>
        public string texts
        {
            get
            {
                try { return (string)this.DataRow["texts"]; }
                catch { return string.Empty; }
            }
            set
            {
                this.DataRow["texts"] = value;
            }
        }
        /// <summary>
        /// 作者
        /// </summary>
        public string Author
        {
            get
            {
                try { return (string)this.DataRow["Author"]; }
                catch { return string.Empty; }
            }
            set
            {
                this.DataRow["Author"] = value;
            }
        }
        /// <summary>
        /// 文章添加时间
        /// </summary>
        public DateTime AddTime
        {
            get
            {
                try { return (DateTime)this.DataRow["AddTime"]; }
                catch { return DateTime.Now; }
            }
        }
        /// <summary>
        /// 审核
        /// </summary>
        public int Shenhe
        {
            get
            {
                try { return (int)this.DataRow["Shenhe"]; }
                catch { return 0; }
            }
            set
            {
                this.DataRow["Shenhe"] = value;
            }
        }
        /// <summary>
        /// 排序
        /// </summary>
        public int Sort
        {
            get
            {
                try { return (int)this.DataRow["Sort"]; }
                catch { return 0; }
            }
            set
            {
                this.DataRow["Sort"] = value;
            }
        }
        /// <summary>
        /// 浏览次数
        /// </summary>
        public int hits
        {
            get
            {
                try { return (int)this.DataRow["hits"]; }
                catch { return 0; }
            }
            set
            {
                this.DataRow["hits"] = value;
            }
        }
        
        /// <summary>
        /// 活动时间
        /// </summary>
        public string HDTime
        {
            get
            {
                try { return (string)this.DataRow["HDTime"]; }
                catch { return string.Empty; }
            }
            set
            {
                this.DataRow["HDTime"] = value;
            }
        }
    }
    public class SmallClassTable : DBTable
    {
        private const string tableName = "News_small_type";
        public SmallClassTable()
            : base(GetHandler.Init(), tableName)
        {
            this.GetRow();
            //没有参数重载
        }
        public SmallClassTable(int Smallid)
            : base(GetHandler.Init(), tableName)
        {
            this.Filter = "smallclassid=?";
            this.AddParameter("smallclassid", Smallid);
            this.GetRow();
            //没有参数重载
        }
        /// <summary>
        /// 小类名称
        /// </summary>
        public string SmallClassName
        {
            get
            {
                try { return (string)this.DataRow["smallclassname"]; }
                catch { return string.Empty; }
            }
            set
            {
                this.DataRow["smallclassname"] = value;
            }
        }
        /// <summary>
        /// 小类Url
        /// </summary>
        public string SmallClassUrl
        {
            get
            {
                try { return (string)this.DataRow["smallclassurl"]; }
                catch { return string.Empty; }
            }
            set
            {
                this.DataRow["smallclassurl"] = value;
            }
        }
        /// <summary>
        /// 所属大类ID
        /// </summary>
        public int ForBigClassID
        {
            get
            {
                try { return (int)this.DataRow["forbigclass"]; }
                catch { return 0; }
            }
            set
            {
                this.DataRow["forbigclass"] = value;
            }
        }
        /// <summary>
        /// 所属大类名称(只读)
        /// </summary>
        public string ForBigClassName
        {
            get
            {
                try { return (new BigClassTable(this.ForBigClassID).bigclassname); }
                catch { return string.Empty; }
            }
        } 
    }
    public class BigClassTable : DBTable
    {
        private const string tableName = "News_big_type";
        public BigClassTable()
            : base(GetHandler.Init(), tableName)
        {
            this.GetRow();
            //没有参数重载
        }
        public BigClassTable(int Bigid)
            : base(GetHandler.Init(), tableName)
        {
            this.Filter = "bigclassid=?";
            this.AddParameter("bigclassid", Bigid);
            this.GetRow();
            //没有参数重载
        }
        /// <summary>
        /// 大类名称
        /// </summary>
        public string bigclassname
        {
            get
            {
                try { return (string)this.DataRow["bigclassname"]; }
                catch { return string.Empty; }
            }
            set
            {
                this.DataRow["bigclassname"] = value;
            }
        }        
        /// <summary>
        /// 外部Url
        /// </summary>
        public string bigclassurl
        {
            get
            {
                try { return (string)this.DataRow["bigclassurl"]; }
                catch { return string.Empty; }
            }
            set
            {
                this.DataRow["bigclassurl"] = value;
            }
        }

    }

}